#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 10

typedef struct {
	int data[MAX_SIZE];
	int front;
	int real;
} Queue;

void initQueue(Queue *q) {
	q->front = 0;
	q->real = -1;
}

int isFull(Queue *q) {
	return q->real == MAX_SIZE - 1;
}

int isEmpty(Queue *q) {
	return q->front == q->real + 1;
}

void enqueue(Queue *q, int value) {
	if (isFull(q)) {
		printf("Queue in full.Cannot enqueue.\n");
		return;
	}
	q->real++;
	q->data[q->real] = value;
}

int dequeue(Queue *q) {
	if (isEmpty(q)) {
		printf("Queue is empty.\n");
		return -1;
	}
	int value = q->data[q->front];
	q->front++;
	return value;
}

void printQueue(Queue *q) {
	if (isEmpty(q)) {
		printf("Queue is empty,\n");
		return;
	}
	for (int i = q->front; i <= q->real; i++) {
		printf("%d ", q->data[i]);
	}
	printf("\n");
}

int main() {
	Queue q;
	initQueue(&q);
	for (int i = 0; i < 10; i++) {
		enqueue(&q, i);
	}
	printQueue(&q);
	while (!isEmpty(&q)) {
		printf("%d ", dequeue(&q));
	}
	printf("%d");
	return 0;
}